/* 
 *  Copyright 2012 CodeMagi, Inc.
 * 
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package com.codemagi.servlets.model;

import com.codemagi.login.model.IUser;
import com.codemagi.util.Utils;
import java.io.Serializable;

public class AdminLink extends BaseBean implements Serializable, Securable {
    
    private String description;
    private String groupName;
    private String context;
    private String link;


    //GETTERS AND SETTERS -----------------------------------------------------

    public void setDescription(String newValue) {
	description = newValue;
    }

    public String getDescription() {
	return description;
    }

    public void setGroupName(String newValue) {
	groupName = newValue;
    }

    public String getGroupName() {
	return groupName;
    }

    public void setContext(String newValue) {
	context = newValue;
    }

    public String getContext() {
	return context;
    }

    public void setLink(String newValue) {
	link = newValue;
    }

    public String getLink() {
	return link;
    }


    //SPECIAL GETTERS AND SETTERS ----------------------------------------

    /**
     * Implementation of the Securable interface
     */
    public boolean hasUser(IUser user) {
	if (user == null || user.getId() == null) return false;

	if (Utils.isEmpty(groupName)) return true;

	return user.isInGroup(groupName);
    }

}
